﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<script>
    $(function () {
        initControl();
        gridList();
    });
    function initControl() {
        $('#ProductType').bindSelect();
        $('#AssembleLine').bindSelect();
        $('#FOrderNum').bindSelect({search:true});
    }
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/BOM/Manufacture/GetUnitStampingJson",
            postData: $("#form1").formSerialize(),
            height: $(window).height() - 118,
            colModel: [
                { label: '装配路线', name: 'AssembleLine', width: 60, align: 'center', sortable: false },
                { label: '装配路线名称', name: 'AssembleLineName', width: 100, align: 'left', sortable: false },
                { label: '零件编号', name: 'FProductionNO', width: 120, align: 'left', sortable: false },
                { label: '零件名称', name: 'FProductionName', width: 200, align: 'left', sortable: false },
                { label: '零件属性', name: 'ProductTypeName', width: 80, align: 'center', sortable: false },
                { label: '制造路线', name: 'MakeLine', width: 160, align: 'left', sortable: false },
                {
                    label: '数量', name: '', width: 40, align: 'right', sortable: false, formatter: function (cellvalue, options, rowObject) {
                        var currId = $('#FOrderNumHidden').val();
                        if(currId != ''){
                            var fieldName = ('00' + currId).slice(-3);
                            fieldName = 'ProductSum' + fieldName;
                            //alert(fieldName);
                            if(rowObject.hasOwnProperty(fieldName)){
                                return rowObject[fieldName]
                            }else{
                                return '';
                            }
                        }else{
                            return '';
                        }
                    }
                },
                { label: '备注', name: 'MakeLineName', width: 300, align: 'center', sortable: false }
            ],
            pager: "#gridPager",
            sortname: 'AssembleLine ASC, FProductionNO ASC',
            rownumWidth: 40,
            viewrecords: true
        });
        $gridList.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
        $("#btn_search").click(function () {
            $('#FOrderNumHidden').val($('#FOrderNum').val());
            $gridList.jqGrid('setGridParam', {
                postData: $("#form1").formSerialize(),
            }).trigger('reloadGrid');
        });
    }
</script>
<div id="layout" style="height: 100%; width: 100%;">
    <form id="form1">
        <div style="padding: 12px 0 5px 0; padding-left: 15px; border-bottom: 1px solid #ccc;" class="line-table">
            <div class="btn-group input-width-160" style="margin-top:-9px;">
                装配路线<br />
                <select id="AssembleLine" name="AssembleLine" class="form-control">
                    <option value="">&nbsp;</option>
                    @foreach (var item in ViewBag.assembleLine)
                    {
                        <option value="@item.MakeLineNO">@item.MakeLineNO @item.MakeLineName</option>
                    }
                </select>
                &nbsp;
            </div>
            <div class="btn-group input-width-240" style="margin-top:-9px;">
                车型编号<br />
                <select id="FOrderNum" name="FOrderNum" class="form-control">
                    <option value="">&nbsp;</option>
                    @foreach (var item in ViewBag.productList)
                    {
                        <option value="@item.FOrderNum">@item.FProductNO</option>
                    }
                </select>
                <input id="FOrderNumHidden" type="hidden" value="" />
                &nbsp;
            </div>
            <div class="btn-group input-width-140" style="margin-top:-9px;">
                零件<br /><input id="FProduction" name="FProduction" type="text" class="form-control" /> &nbsp;
            </div>
            <div class="btn-group input-width-120" style="margin-top:-9px;">
                零件属性<br />
                <select id="ProductType" name="ProductType" class="form-control">
                    <option value="">&nbsp;</option>
                    @foreach (var item in ViewBag.productType)
                    {
                        <option value="@item.FTypeNO">@item.FTypeNO @item.FTypeName</option>
                    }
                </select>
                &nbsp;
            </div>
            <div class="btn-group input-width-160" style="margin-top:-9px;">
                制造路线<br /><input id="MakeLine" name="MakeLine" type="text" class="form-control" /> &nbsp;
            </div>
            <div class="btn-group" style="">
                <a id="btn_search" class="btn btn-primary center-block" onclick=""><span class="glyphicon glyphicon-search"></span> 检索</a>
            </div>
            <div class="btn-group" style="float:right;">
                <a id="" class="btn btn-primary center-block" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span> 刷新</a>
                @*<a id="" class="btn btn-primary center-block disabled" onclick=""><span class="glyphicon glyphicon-download"></span> 导出</a>*@
            </div>
        </div>
    </form>
    <div style="">
        <table id="gridList"></table>
        <div id="gridPager"></div>
    </div>
</div>
